/**
 * Copyright (c) 2009  Collaborative Development Group, C.S. Dept., University of Bari
 *
 * All rights reserved. This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
 * available at http://www.eclipse.org/legal/epl-v10.html
 */
package it.uniba.di.cdg.jtalk.ui.chat;

import it.uniba.di.cdg.penelope.presenterfirst.SUT;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

/**
 * GUI BDD Tests for Chat Presenter.
 */
@RunWith( MockitoJUnitRunner.class ) 
public class ChatGUIStoryTest {
	@Mock
	private IChatEditor editor;
	@Mock
	private IChatPresentationModel presentationModel;	
	@Mock
	private IChatModel model;
	
	@SUT
	private ChatPresenter presenter;

	@Before
	public void createSUT() {
		presenter = new ChatPresenter( editor, presentationModel, model );
	}

	@Test
	public void whenTextToSendIsEmptySendMessageButtonIsDisabled() {
		// given the presentation model contains empty username and password initially 
		given( presentationModel.getTextToSend() ).willReturn( "" );
		
		// when view is started
		presenter.onViewCreated();
		
		// then the view button is disabled
		verify( editor ).enableSendMessageButton( false );
	}
}
